// pages/waybillDetail/waybillDetail.ts
var url = require("../../utils/urls");
var commons = require("../../utils/common");
var tip = require("../../utils/tip");
var modelData = require("../../utils/data");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    waybillNumber: "",
    item: {},
    path: ""
  },

  getWaybillList() {
    // console.log(this.data.waybillNumber, '运单号')
    commons.get(url.fleetCaptainWaybillTable).then((res) => {
      let resData = res.data
      resData.records.forEach((item, index) => {
        if (item.waybillNumber == this.data.waybillNumber) {
          // console.log(item, 'item')
          this.setData({
            item: item
          })
        }
      });
    }).catch(err => {
      // console.log(err, '0000');
    });
  },

  goUploadInfo(e) {
    console.log(e, 'e000')
    let data = e.currentTarget.dataset
    data.path = this.data.path
    wx.navigateTo({
      url: "../uploadInfo/uploadInfo?obj=" + JSON.stringify(data)
    })
  },

  goWaybillBookingDetail(e) {
    let waybillNumber = e.currentTarget.dataset.waybillnumber
    wx.navigateTo({
      url: "../waybillBookingDetail/waybillBookingDetail?waybillNumber=" + waybillNumber,
    })
  },

  call(e) {
    let phone = e.currentTarget.dataset.phone
    commons.callPhone(phone)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {
    console.log(e,'e999')
    if (e.waybillNumber) {
      this.setData({
        waybillNumber: e.waybillNumber,
        path: e.path,
      })
      this.getWaybillList()
    }

    // console.log(e, '运单详情')
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
    this.getWaybillList()
    setTimeout(() => {
      wx.stopPullDownRefresh()
    }, 1000)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})